﻿// this function is fired when the document is in the ready state.
function documentLoad() {
    $('#loginDiv').dialog({
        autoOpen: true,
        width: 500,
        height: 'auto',
        resizable: false
    });

    $('#passwordForgotDiv').dialog({
        autoOpen: false,
        width: 500,
        height: 'auto',
        resizable: false,
        title: "Forgot password"
    });

    $("#btnSendPassword").click(function() {
        var imgLoading = $("#imgLoading")[0];
        var txtEmail = $("#txtEmail")[0];
        if (removeSpaces(txtEmail.value) == "") return;
        $("#error")[0].innerHTML = "";
        /* Show loading image */
        imgLoading.style.display = "block";
        var input = { "emailAddress": txtEmail.value };
        CallWebService(membershipPasswordRetrieveUrl, input,
        /* Callback function */
            function(serviceResult) {
                var imgLoading = $("#imgLoading")[0];
                /* Hide loading image */
                imgLoading.style.display = "none";
                var response = JSON.parse(serviceResult.d);
                var result = response.Payload;
                if (response.IsSuccess == false) {
                    $("#error")[0].style.color = "red";
                }
                else {
                    $("#error")[0].style.color = "black";
                }
                $("#error")[0].innerHTML = result;
            });
    });
}

function Login_Open() {
    $('#loginDiv').dialog('open');
}

function Close_Login() {
    $('#loginDiv').dialog('close');
}

function Close_PasswordForgot() {
    $('#passwordForgotDiv').dialog('close');
    Login_Open();
}

function ShowPasswordForgot() {
    Close_Login();
    $('#passwordForgotDiv').dialog('open');
}